-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Block conversion update: ability to convert objects with advanced configuration #2824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
According to the workflow script from the documentation: https://editorjs.io/tools-api/#conversionconfig
|
Thanks for the PR. Could you show the example of the conversion configs in Image Tool and Gallery tools? |
For example, the SimpleImage export I did it this way: export: function (blockData) {
return {
'url': blockData.url,
'caption': blockData.caption
}
}And for ImageTool this way: export: function (blockData) {
return {
'file': blockData.file,
'caption': blockData.caption
}
}And for Gallery I made a universal way to handle both variants, otherwise returning undefined: import: function (exportData) {
if (typeof exportData !== 'object') return;
let blockData = {};
if (exportData.url) {
blockData.files = [{ url: exportData.url }];
} else if (exportData.file) {
blockData.files = [exportData.file];
} else {
return;
}
if (exportData.caption) {
blockData.caption = exportData.caption;
}
return blockData;
} |
|
The problem now is that Gallery tool in your example knows about other tools: SimpleImage and ImageTool. It is a bad practice for our design. That is why we designed conversion through the string data. As a solution, we can improve ImageTool by supporting multiple images in a gallery-view. |
|
I interpret this not as the block knows about these tools, but that this block is ready to accept data in a certain format. And Image blocks give their data in a more structured format. So it doesn't mean that Gallery only works with these Image blocks, and that Image blocks will only work with Gallery. They will only be able to have more extended interfaces for sharing structured data. |
|
Or maybe do something similar to Clipboard, allowing export to text/plain and text/html. HTML5 is advanced enough that it can be used to explicitly deliver various data structures, including lists, image galleries, etc. |
I don't see any options at the moment. Transferring data should be abstracted away from any tool's data format. Maybe markdown would work better that just simple strings. We'll think about it when we'll design a markdown support (in Tools API first of all) |
…codex-team#2891) * fix(inline-tools): inline tools shortcuts now works in read-only mode * use ubuntu-20.04 instead of latest
…-team#2880) * update all submodules * rm checklist and nested list submodule * Update .gitmodules * rm list submodule * add list submodule * all submodules updated * fix(inline-tools): inline tools shortcuts now works in read-only mode
Co-authored-by: github-actions <[email protected]>
…2865) * fix: handle whitespace input in empty placeholders correctly * fix: isNodeEmpty() to handle visible whitespaces * chore: bump version from 2.31.0-rc.5 to 2.31.0-rc.6 * chore: bump version from 2.31.0-rc.5 to 2.31.0-rc.6 * fix: submodules updated * fix: eslint errors * test: backspace removes trailing spaces, hides placeholder in empty blocks * fix: update incorrect tests * fix: resolving submodules issue * Create list --------- Co-authored-by: Peter Savchenko <[email protected]>
* rm all submodules * rm commands * Update package.json
* Bug Fix For When / Overides external text * Moved fix to blockEvents * Moved fix to blockEvents * Moved fix to blockEvents * Refactored test to simulate behaviour * Added fix to change log * Refactored test to mimick exact behaviour of the bug --------- Co-authored-by: Omotayo Obafemi <[email protected]> Co-authored-by: Peter <[email protected]>
* Added fix for memory leak issue * Documented the fix in docs/CHANGELOG.md * v2.31.0 * Documented the fix in docs/CHANGELOG.md * Documented the fix in docs/CHANGELOG.md * Documented the fix in docs/CHANGELOG.md * Documented the fix in docs/CHANGELOG.md --------- Co-authored-by: Omotayo Obafemi <[email protected]> Co-authored-by: Peter Savchenko <[email protected]>
Co-authored-by: github-actions <[email protected]>
…odex-team#2918) * fix: prevent flipper navigation when shift key is pressed * rm logs * feat: improve line selection with Shift + Up/Down * fix lint action * fix action * upd
Co-authored-by: github-actions <[email protected]>
…x-team#2922) * chore(caret): caret.setToBlock offset improved * handle empty block * Update caret.cy.ts * fix eslint
…-team#2941) * fix(blocks):Error occurred when calling renderFromHTML: Can't find a Block to remove. * fix: resolve "Can't find a Block to remove" error in renderFromHTML - Make renderFromHTML async and await BlockManager.clear() to prevent race condition - Change removeBlock order: remove from array before destroy to prevent index invalidation - Fix clear() method to copy blocks array before iteration to avoid modification during loop Fixes issue where renderFromHTML would fail with "Can't find a Block to remove" error due to concurrent block removal operations and array modification during iteration. Resolves codex-team#2518
Hello!

Right now block conversions are performed using a string only, which does not allow for complex conversions.
For example, it will not be possible to convert text blocks separately and image blocks separately, like this:
Right now it is not possible to send a complex configuration from an image block to a gallery block (file data + caption) via string. In addition, there is no conversion filtering now, so if a block exports something, it will be listed for import in all blocks, even if it is not suitable for conversion.
I made a few changes to make it all possible: